export default class Home extends Laya.Script {

   

    constructor() { super(); }


    onAwake(): void {
        console.log('home is on awake.');

        // 场景初始化，搭建好舞台。自己是导演（什么活都干的导演）
        let scene:Laya.Scene3D = new Laya.Scene3D() as Laya.Scene3D;
        Laya.stage.addChild(scene);

        // 摄像机，叫摄像come on baby
        let camera:Laya.Camera = new Laya.Camera(0,0.1,100) as Laya.Camera;
        
        scene.addChild(camera);

        camera.transform.translate(new Laya.Vector3(0,3,3)); 
        camera.transform.rotate(new Laya.Vector3(-30,0,0),true,false);

       

        //演员  cube
        let box:Laya.MeshSprite3D=new Laya.MeshSprite3D(Laya.PrimitiveMesh.createBox(1,1,1));
        scene.addChild(box);
        box.transform.translate(new Laya.Vector3(0,0,0));
        box.transform.rotate(new Laya.Vector3(0,30,0),true,false);
    
        // 演员的衣服
        let material:Laya.BlinnPhongMaterial = new Laya.BlinnPhongMaterial();

        Laya.Texture2D.load('res/layabox.png',Laya.Handler.create(this, (tex:Laya.Texture2D)=>{
            material.albedoTexture = tex;
        }));
        box.meshRenderer.material = material;

        // 灯光
        let directionLight:Laya.DirectionLight = new Laya.DirectionLight();
        scene.addChild(directionLight);
        directionLight.color=new Laya.Vector3(0.6,0.6,0.6);
        directionLight.transform.worldMatrix.setForward(new Laya.Vector3(1,-1,0));
        

    }
    onEnable():void{

    }

    onStart(): void {
    }

}